//
//  ZWStatuses.swift
//  ZWWeibo
//
//  Created by flyiron on 16/4/20.
//  Copyright © 2016年 flyiron. All rights reserved.
//

import UIKit

class ZWStatuses: NSObject {
    //当前微博内容
    var text: String?
    //微博创建事件
    var created_at: String?
    //来源
    var source: String?
    //用户信息
    var user: ZWStatusUser?
    //转发信息
    var retweeted_status: ZWStatuses?
    //配图数组
    var pic_urls:[ZWStatusPhotoInfo]?
    //微博id
    var id: Int64 = 0
    
    init(dict:[String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user"{
            guard let dict = value as? [String : AnyObject] else{
                return
            }
            user = ZWStatusUser.init(dict: dict)
        }else if key == "retweeted_status"{
            guard let dict = value as? [String : AnyObject] else{
                return
            }
            retweeted_status = ZWStatuses.init(dict: dict)
        }else if key == "pic_urls" {
            guard let dicts = value as? [[String : AnyObject]] else{
                return
            }
            var arr = [ZWStatusPhotoInfo]()
            for dict in dicts{
                let model = ZWStatusPhotoInfo.init(dict: dict)
                arr.append(model)
            }
            pic_urls = arr
//            print(pic_urls?.count)
          
        }else{
            super.setValue(value, forKey: key)
        }
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
}
